Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(semver): clean up parseRange, add missing tests #6362

Merged
merged 13 commits into from
Feb 12, 2025

Conversation

timreichen
Copy link
Contributor

No description provided.

@timreichen timreichen requested a review from kt3k as a code owner January 24, 2025 08:10
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.30%. Comparing base (3b75ee7) to head (6ed9efb).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
semver/parse_range.ts 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6362      +/-   ##
==========================================
+ Coverage   96.23%   96.30%   +0.06%     
==========================================
  Files         556      556              
  Lines       42065    42063       -2     
  Branches     6371     6371              
==========================================
+ Hits        40481    40507      +26     
+ Misses       1544     1517      -27     
+ Partials       40       39       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

prerelease: [],
build: [],
}]];
assertEquals(lessThanRange(version, range), true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This result feels wrong to me. I'd suggest skipping this test case for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not skip test cases if they yield unexpected results but fix them instead. What would the proper result be?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would the proper result be?

The range != 1.0.0 should include all versions except 1.0.0. So I think the expected result here is false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to create a PR to remove the != straight away as a bug fix before landing this PR? This probably solves lots of headaches with intermediate patches.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will be a breaking change and we currently don't have a plan for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this bug could be fixed by modifying the != case to return cmp === 0; instead of return false; in greaterThanComparator() and lessThanComparator(). Then it will return the expected false.

semver/parse_range_test.ts Outdated Show resolved Hide resolved
});

Deno.test({
name: "compare() handles undefined in prerelease",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case looks comparing invalid semvers. I don't think this is an intentional behavior, but an undefined behavior. I'd suggest we should remove this test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is undefined behavior we probably should remove if (a === undefined && b === undefined) return 0; from compareIdentifier() as this is specifically handled there.

@kt3k kt3k changed the title test(semver): add missing tests refactor(semver): clean up parseRange, add missing tests Feb 10, 2025
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I changed the commit type to refactor as this PR modifies parseRange implementation. (We use test commit type when the changes are only about testing.)

@kt3k kt3k merged commit 01a8dfd into denoland:main Feb 12, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants